package cn.iocoder.yudao.module.pay.wallet.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

import java.util.Objects;

@Schema(description = "用户 APP - 创建钱包充值 Request VO")
@Data
public class AppPayWalletRechargeCreateReqVO {

    @Schema(description = "支付渠道：alipay_app、wx_lite、wallet", requiredMode = Schema.RequiredMode.REQUIRED, example = "wallet")
    @NotEmpty(message = "支付渠道不能为空")
    private String channelCode;

    @Schema(description = "支付金额，单位为分，支付金额与充值套餐编号二选一，充值套餐编号优先", example = "100")
    @Min(value = 1, message = "支付金额必须大于零")
    private Integer payPrice;

    @Schema(description = "充值套餐编号，支付金额与充值套餐编号二选一，充值套餐编号优先", example = "1024")
    private Long packageId;

    @JsonIgnore
    @AssertTrue(message = "充值金额和充钱套餐不能同时为空")
    public boolean isValidPayPriceAndPackageId() {
        return Objects.nonNull(payPrice) || Objects.nonNull(packageId);
    }

}
